#!/bin/bash
#
# Can a computer generate people's names that are convincing enough to fool a
# human inspector?
#
# The Unix words file may help you wonders!
#
# USAGE: namegen [# of names]
#
# Copyright 2016 Klaus Zimmermann - https://quitter.se/kzimmermann
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#

# In Debian, this is where the file is located:
DICT="/usr/share/dict/words"

# How many full names do we default to?
TIMES=1

# Attempt to find given names and build a full name
generate() {
cat "$DICT" | 
    shuf | 
    grep [A-Z].* |      # They start with capitals...
    sed "s/'s//g" |     # But don't contain apostrophes.
    head -3 |           # Try to string a few names to build a full name
    tr "\n" " "         # and put them inline!
echo
}

if [[ -n "$1" ]]
then
    TIMES="$1"
fi

for i in $(seq 1 "$TIMES")
do
    generate
done
